package com.javasm.adminapi.module.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.javasm.adminapi.module.system.dao.RoleDao;
import com.javasm.adminapi.module.system.entity.Permission;
import com.javasm.adminapi.module.system.entity.Role;
import com.javasm.adminapi.module.system.service.PermissionService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @className: RoleApiServiceImpl
 * @description:
 * @author: zcx
 * @date: 2025/10/16 22:17
 * @version: 0.1
 * @since: jdk17
 */
@Service("roleApiService")
@Log4j2
public class RoleApiServiceImpl extends ServiceImpl<RoleDao, Role> {
    @Resource
    PermissionService permissionService;

    public Role getByRid(Long userRoleId) {
        //根据用户的角色id查询角色
        Role role = getById(userRoleId);
        if (role!=null){
            //根据角色id查询权限
            List<Permission> list = permissionService.getByRid(role.getId());
            role.setMenuList(list);
        }
        return role;
    }
}
